package com.yirui.serialcomm.core.domain;

/**
 * @author Dujie
 * @create 2025/8/13
 * @since 1.0.0
 */
public class SimpleSerialCommPacket implements SerialCommPacket{
    private StreamType type;
    private byte[] data;

    public SimpleSerialCommPacket(StreamType type, byte[] data){
        this.type = type;
        this.data = data;  // 防御性拷贝
    }
    @Override
    public StreamType getType() {
        return type;
    }

    @Override
    public byte[] getData() {
        return data;
    }

    @Override
    public int getSize() {
        return data == null?0:data.length;
    }

    @Override
    public void setData(byte[] data) {
        this.data = data;
    }
}
